import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GoodsSpecGroupVO, GoodsSpecGroupForm, GoodsSpecGroupQuery } from '@/api/order/goodsSpecGroup/types';

/**
 * 查询商品规格分组列表
 * @param query
 * @returns {*}
 */

export const listGoodsSpecGroup = (query?: GoodsSpecGroupQuery): AxiosPromise<GoodsSpecGroupVO[]> => {
    return request({
        url: '/order/goodsSpecGroup/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询商品规格分组详细
 * @param id
 */
export const getGoodsSpecGroup = (id: string | number): AxiosPromise<GoodsSpecGroupVO> => {
    return request({
        url: '/order/goodsSpecGroup/' + id,
        method: 'get'
    });
};
/**
 * 查询商品规格分组详细
 * @param id
 */
export const getGoodsSpecGroupAllList = (id: string | number): AxiosPromise<GoodsSpecGroupVO> => {
    return request({
        url: '/order/goodsSpecGroup/allList',
        method: 'get'
    });
};

/**
 * 新增商品规格分组
 * @param data
 */
export const addGoodsSpecGroup = (data: GoodsSpecGroupForm) => {
    return request({
        url: '/order/goodsSpecGroup',
        method: 'post',
        data: data
    });
};

/**
 * 修改商品规格分组
 * @param data
 */
export const updateGoodsSpecGroup = (data: GoodsSpecGroupForm) => {
    return request({
        url: '/order/goodsSpecGroup',
        method: 'put',
        data: data
    });
};

/**
 * 删除商品规格分组
 * @param id
 */
export const delGoodsSpecGroup = (id: string | number | Array<string | number>) => {
    return request({
        url: '/order/goodsSpecGroup/' + id,
        method: 'delete'
    });
};
export default {
    list: listGoodsSpecGroup,
    get: getGoodsSpecGroup,
    add: addGoodsSpecGroup,
    update: updateGoodsSpecGroup,
    del: delGoodsSpecGroup,
}